# Contributor: Andrew Hills <ahills@ednos.net>
# Contributor: Jean-Louis Fuchs <jean-louis.fuchs@adfinis-sygroup.ch>
# Maintainer: Jean-Louis Fuchs <jean-louis.fuchs@adfinis-sygroup.ch>
pkgname=libspectre
pkgver=0.2.12
pkgrel=1
pkgdesc="A small library for rendering Postscript documents"
url="https://www.freedesktop.org/wiki/Software/libspectre"
arch="all"
license="LGPL-2.0-or-later"
makedepends="ghostscript-dev doxygen graphviz"
checkdepends="cairo-dev file"
subpackages="$pkgname-dev $pkgname-doc"
source="https://libspectre.freedesktop.org/releases/libspectre-$pkgver.tar.gz
	test.ps
	"

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var
	make
	make doc
}

check() {
	cd "$builddir/test"
	make
	mkdir work
	./parser-test "$srcdir/test.ps" work
	./spectre-test "$srcdir/test.ps" work
	file work/output.ps |
		grep -q "PostScript document text conforming DSC level 3.0, Level 2" || \
		error "Failed PostScript test"
	file work/output.pdf | grep -q "PDF document, version 1.7" || error "Failed PDF test"
	file work/document.png | grep -q "PNG image data" || error "Failed png test"
}

package() {
	make DESTDIR="$pkgdir" install
}

doc() {
	mkdir -p "$subpkgdir/usr/share/doc/$pkgname"
	install -m644 "$builddir"/doc/html/* \
		"$subpkgdir/usr/share/doc/$pkgname/"
}

sha512sums="
3a4045c1e94e7de23b437393389397dd2448363458023b5aa8e43fa0553a160216f038e157374cefc1d09fa74711ad4899aac1fc353c482bd5fe970d9a97461f  libspectre-0.2.12.tar.gz
c5148d38da69ebd125f66bb92204f2c7c79797d60a137d431122792c4e4cdcdb3a6a20cfadadd2821536449b1d638258f4596e43154e1ad2307bffa97af4908b  test.ps
"
